<cpanel include="../../config.php">

<?

/***************************************************************************
 *                                 mx.php
 *                            -------------------
 *   Begin                : Thursday, April 16, 2005
 *   Copyright            : (C) 2005 Point and Code
 *   Domain               : http://www.pointandcode.com/
 *   Email                : support@pointandcode.com
 *   Version              : 1.1.0
 *
 ***************************************************************************/

/***************************************************************************
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 ***************************************************************************/

$html_root_path = '../../';
$page_title = "Mail Exchanger (MX) Entries";
include $root_path.'common.php';
include $root_path.'page_header.php';

/*
Note: this section originally formatted things as Domain : Destination. Sometime before 22/05/05 it changed to <tr><td>Domain</td><td>Destination</td></tr>. Not sure when this changeover happened, otherwise I'd have put an if (version) else in. If you're using a version of cpanel which uses the old output, then try grabbing the code from one of the first two beta's.
*/


$big_wadge_of_stuff = <<<EOFpacman
<cpanel Email="listmxs()">
EOFpacman;

//
// Split up into lines...
//
$array_of_mx_with_junk = array();
$array_of_mx_with_junk = explode('</tr>', $big_wadge_of_stuff);

$array_of_mx = array();
$i=0;

foreach($array_of_mx_with_junk as $row) {

	$temp = explode('<td>', $row);
	
	$temp2 = explode('</td>', $temp[1]);
	$array_of_mx[$i]['domain'] = trim($temp2[0]);

	$temp2 = explode('</td>', $temp[2]);
	$array_of_mx[$i]['destination'] = trim($temp2[0]);

	$i++;
}


$template->set_filenames(array(
	'body' => $root_path.$template_path.'mail/mx.tpl')
);

$i = 0;
foreach ($array_of_mx as $row) {

	if (!empty($row['domain'])) {
		$template->assign_block_vars('mxrow', array(
			'ROWCLASS' => ($i%2) ? $template_cfg['class_row_1'] : $template_cfg['class_row_2'],
			'DOMAIN' => $row['domain'],
			'DESTINATION' => $row['destination'],
			
			'U_EDIT' => 'mx_edit.php?destination='.$row['destination'].'&domain='.$row['domain'],
			)
		);
	$i++;
	}

}

//
// Woohoo! All done!
//
$template->pparse('body');




include $root_path.'page_tail.php';


?>